import axios from 'axios'
import Vue from 'vue'
import { Toast } from 'vant'
Vue.use(Toast)
const http = axios.create({
  baseURL: 'https://m.maizuo.com',
  timeout: 10000,
  headers: {
    'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.0.4","e":"16136417063439624559001601"}'
  }
})
http.interceptors.request.use(function (config) {
  Toast.loading({
    message: '加载中...',
    overlay: true,
    forbidClick: true,
    loadingType: 'spinner',
    duration: 2000
  })
  return config
}, function (error) {
  return Promise.reject(error)
})
http.interceptors.response.use(function (respons) {
  Toast.clear()
  return respons
}, function (error) {
  return Promise.reject(error)
})
export default http
